#include"my_map.h"
#include<opencv.hpp>
using namespace cv;
Mat img0, img1;
void read_map(string mapdir)
{
	img0 = imread(mapdir);
	cvtColor(img0, img1, COLOR_BGR2GRAY);
}
bool test_obstacle(int x, int y)
{
	if (x < 0 || y < 0)
		return 1;
	if (x >= img1.cols || y >= img1.rows)
		return 1;
	if (img1.ptr<uchar>(y)[x] > 127)
		return 0;
	return 1;
}
void add_closelist(int x, int y)
{
	circle(img0, Point(x, y), 0, Scalar(200, 200, 200), -1);
}
bool test_closelist(int x, int y)
{
	uchar b = img0.at<Vec3b>(y, x)[0];
	uchar g = img0.at<Vec3b>(y, x)[1];
	uchar r = img0.at<Vec3b>(y, x)[2];
	if (b == 200 && g == 200 && r == 200)
		return true;
	else
		return false;
}
void draw_point(int x, int y)
{
	circle(img0, Point(x, y), 0, Scalar(0, 0, 255), -1);
}
void mapshow()
{
	imshow("test", img0);
	waitKey(10);
}
void mapwrite()
{
	imwrite("test.png", img0);
}